extends Area2D
class_name HitBoxComponent


signal on_hit_hurtbox(hurtbox: HurtBoxComponent)

var damage: float = 1
var critical := false
var knockback_power := 0.0
var source: Node2D


func enable() -> void:
	set_deferred("monitoring", true)
	set_deferred("monitorable", true)

func disable() -> void:
	set_deferred("monitoring", false)
	set_deferred("monitorable", false)

func setup(_damage: float, _critical: bool, _knockback_power: float, _source: Node2D) -> void:
	print("setup damage: ", _damage)
	self.damage = _damage
	self.critical = _critical
	self.knockback_power = _knockback_power
	self.source = _source

func _on_area_entered(area: Area2D) -> void:
	if area is HurtBoxComponent:
		on_hit_hurtbox.emit(area)
		print(area.owner.name)
